' oh Interpreter - Fill Circle Bresenham Style  b+ 2021-05-08

' center our origin on fixed screen 1024 X 672 and setup colors
cx = d[xmax,2]
cy = d[ymax,2]
r = 100
ink 255;0;0
paper 0;0;0
cls
' call the circle fill sub
gs fcirc\
end

fcirc\ 
    radius = abs[r]
	radiusError = x[radius,-1]
	x = radius
	y = 0
    if eq[radius,0]
		pix cx;cy
		rtn
	fi
    line s[cx,x];cy;a[cx,x];cy
	[
		jmp lte[x,y]
        radiusError = a[radiusError,x[y,2],1]
        if gte[RadiusError,0]
            if noteq[x,a[y,1]]
                line s[cx,y];s[cy,x];a[cx,y];s[cy,x]
                line s[cx,y];a[cy,x];a[cx,y];a[cy,x]
            fi
            x = s[x,1]
            radiusError = s[radiusError,x[x,2]]
        fi
        y = a[y,1]
        line s[cx,x];s[cy,y];a[cx,x];s[cy,y]
        line s[cx,x];a[cy,y];a[cx,x];a[cy,y]
	]
rtn